package com.bwie.house.conmap;

/**
 * @author 龙
 * @version 1.0.0
 * @ClassName UrlMap.java
 * @Description TODO
 * @createTime 2022年05月12日 20:15:00
 */

import com.bwie.common.vo.ApiEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

/**
* @Author: 龍
* @Description: 通过经纬度获取地址
* @DateTime: 2022/5/12 20:15
* @Params:
* @Return:
*/
public class UrlMap {
    public static String authorization(String longitude){
        ApiEntity apiEntity = new ApiEntity();
        String host = "http://staticmap.market.alicloudapi.com";
        String path = "/v3/staticmap";
        String method = "GET";
        String appcode = "489208f833cc412da21add31364c5efc";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        System.out.println("经纬度："+longitude);   //经纬度
        querys.put("location",longitude);  //地图中心点坐标  -- 经纬度
        querys.put("markers",apiEntity.getMarkers());  //经纬度
        querys.put("zoom",apiEntity.getZoom());  //清晰度
        querys.put("size",apiEntity.getSize());  //地图大小
        querys.put("key",apiEntity.getKey());  //key

        HttpResponse response;
        {
            try {
                response = HttpUtilsAliyun.doGet(host, path, method, headers, querys);
                //System.out.println(response.toString());
                System.out.println(EntityUtils.toString(response.getEntity()));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        String url="https://restapi.amap.com/v3/staticmap?markers="+querys.get("markers")+querys.get("location")+"&zoom="+querys.get("zoom")+"&size="+querys.get("size")+"&key="+querys.get("key")+"";
        System.out.println("路径："+url);
        return url;
    }
}
